<template>
    <div class="app-download-warp">
        <img src="http://img.uuuda.com/udaWeapp2.0/icon/down/app_down_logo.png" class="down-bg"/>
        <img src="http://img.uuuda.com/udaWeapp2.0/icon/app/download-btn.png" class="down-android" @click="openApp('ios')" v-if="iosShow"/>
        <img src="http://img.uuuda.com/udaWeapp2.0/icon/app/download-btn.png" class="down-android" @click="openApp('and')" v-if="androidShow"/>

        <!--<a href="#" @click="openApp()">-->
            <!--<img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/ios_btn.png" class="down-android"/>-->
        <!--</a>-->
        <!--<a href="#" @click="openApp()">-->
            <!--<img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/android_btn.png" class="down-android"/>-->
        <!--</a>-->

      <div class="app-download-mask" v-if="isAndroid">
          <img src="http://img.uuuda.com/udaWeapp2.0/icon/app/app-download-share.png">
      </div>

    </div>
</template>
<script>
let axios = require("axios");
var d = new Date();
var t0 = d.getTime();
var interval = null;
export default {
    data() {
        return {
            isWeiXin:'',
            isAndroid:false,
            androidShow:false,
            iosShow:false,
            channel:'',

        };
    },

    created() {
        // 请填入对应的 App Key7fe9e4b132fd4a8f
        ShareTrace.init('7fe9e4b132fd4a8f');
        this.isWeiXin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 ? true : false;
        let u = navigator.userAgent;
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1|| u.indexOf('Adr') > -1 ; //g
        let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if (isAndroid) {
            //这个是安卓操作系统
            this.androidShow=true
        }
        if (isIOS) {
            //这个是ios操作系统
            this.iosShow=true

        }else{
            this.androidShow=true
        }

    },
    mounted(){
        let self = this;
        let query = self.$route.query;
        let channel = query.channel || '';
        self.channel=channel
        console.log(channel)
        self.getChannel(channel)

    },

    watch:{


    },
    methods: {
        getChannel:function(channel){
            let self = this;

            axios({
                method: "POST",
                url: "/api/user/setinstallations",
                params: {
                    'origin':channel,
                }
            }).then(function(res) {
                let rdata = res.data;

            });

        },
        openApp:function f(type) {

            // 微信环境
            let self = this

            // self.checkPhone()
            // alert("null")
            // 请在用户点击下载按钮时，触发此函数
            ShareTrace.download();
            let agent = (navigator.userAgent || navigator.vendor || window.opera)

            if (agent != null) {

                // 微信环境
                if(type=='ios'){
                    // 苹果商店链接地址
                    // window.location.href = 'https://www.pgyer.com/lyBZ'
                    window.location.href = 'https://apps.apple.com/cn/app/id1486538835?sid=15473'
                }else {
                    if(self.isWeiXin){
                        self.isAndroid=true;
                    }else {
                        self.isAndroid=false;

                    }
                    window.location.href = 'http://img.uuuda.com/udaWeapp2.0/icon/androidDownLoad/android_xucx.apk'

                }
            }

            }
    },
}

</script>

<style>
    .app-download-warp{
        position: absolute;
        width: 100%;
        height: 100%;
        background: white;
    }
    .down-bg{
        position: relative;
        width: 100%;
    }
    .down-ios{
        position: relative;
        width: 240px;
        height: 48px;
        margin: 0 auto;
        display: block;
    }
    .down-android{
        position: relative; width: 240px;
        height: 48px;
        margin: 48px auto 0 auto!important;
        display: block;


    }
    .app-download-mask{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        background:rgba(0, 0, 0, 0.8);
        z-index: 9999;
    }
    .app-download-mask img{
        position: absolute;
        top: 16px;
        right: 16px;
        display: block;
        width: 172px;
        height: 122px;
    }







</style>
